<extend name="./Application/Admin/View/common/base.html" />
<block name="crumb">
    <span class="c-gray en">&gt;</span> 规格管理
    <span class="c-gray en">&gt;</span> 添加规格
</block>
<block name="content">
    <form class="form form-horizontal" id="add-spec" method="post">
        <input type="hidden" name="iid" value="{$spec['id']}">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>规格名称：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input type="text" name="s_name" class="input-text radius" value="{$spec['s_name']}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"></label>
            <button id="save" class="btn btn-secondary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
        </div>
    </form>
</block>
<block name="js">
    <script type="text/javascript">
        $(function(){

            //添加品牌
            $('#save').click(function (){
                $("#add-spec").validate({
                    rules: {
                        s_name: {required: true}
                    },
                    messages: {
                        s_name: {required: "请输入规格名称"},
                    },
                    submitHandler: function (form) {
                        $(form).ajaxSubmit({
                            type: 'post',
                            url: "{:U('Spec/edit')}",
                            data: {
                                's_name': $("input[name='s_name']").val(),
                                'iid': $('input[name="iid"]').val()
                            },
                            beforeSend: function () {
                                layer.msg('修改规格中..', {icon: 16,time:500});
                            },
                            success: function (msg) {
                                if (msg) {
                                    window.location.href = "{:U('Spec/index')}";
                                }
                            }
                        });
                    }
                });

            });
        });
    </script>
</block>